﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace FigureDraw
{
    public class InputSymbolActivity : InputSymbol
    {
        public InputSymbolActivity(StorageDevice sd)
            : base(sd)
        {
            this.strInfor = "Input";
        }

        public InputSymbolActivity(StorageDevice sd, Infor infor)
            : base(sd, infor)
        {
            
        }

        public override void DrawToDevice(Form form)
        {
            this.R = 255;
            this.G = 0;
            this.B = 0;
            this.LineWidth = 5;
            this.KhoiTaoTruocKhiVe();


            int AB = 100;  //Chiều dài cạnh AB của hình bình hành
            int AD = 50;

            //Cố định kích thước hình
            this.EndPoint = new Point(this.BeginPoint.X + AB, this.BeginPoint.Y + AD);


            Point A, B, C, D, E; // Các đỉnh của hình bình hành. 
            /*
             * A --------B
             * |         |
             * |         C  
             * |         
             * E -----D
             * 
             * */
            A = new Point(this.BeginPoint.X, this.BeginPoint.Y);
            B = new Point(this.BeginPoint.X + AB, this.BeginPoint.Y);
            C = new Point(this.EndPoint.X, this.EndPoint.Y - 10);
            D = new Point(this.EndPoint.X - 15, this.EndPoint.Y);
            E = new Point(this.BeginPoint.X, this.EndPoint.Y);


            //Thêm RichTextBox vào form
            this.rtbInfor.ReadOnly = false;
            this.rtbInfor.Font = new Font("Arial", 12, FontStyle.Bold);
            this.rtbInfor.BorderStyle = BorderStyle.None;
            this.rtbInfor.Text = this.strInfor;
            this.rtbInfor.BackColor = System.Drawing.SystemColors.Menu;
            this.rtbInfor.SelectionAlignment = HorizontalAlignment.Center;
            this.rtbInfor.Location = new Point(BeginPoint.X + 15, BeginPoint.Y + 10);
            this.rtbInfor.Size = new System.Drawing.Size(AB - 30, AD - 20);
            this.rtbInfor.Visible = true;
            if (form != null)
                form.Controls.Add(this.rtbInfor);
            else
                this.StorageDevice.drawString(this.rtbInfor.Text, this.rtbInfor.Font, this.rtbInfor.Location);


            this.StorageDevice.drawLine(A.X, A.Y, B.X, B.Y);
            this.StorageDevice.drawLine(B.X, B.Y, C.X, C.Y);
            this.StorageDevice.drawLine(C.X, C.Y, D.X, D.Y);
            this.StorageDevice.drawLine(D.X, D.Y, E.X, E.Y);
            this.StorageDevice.drawLine(E.X, E.Y, A.X, A.Y);
        }
    }
}
